package com.medication.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.handler.Handler;

public class RequestHandler extends Handler {

	@Override
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
		if (response.getStatus() != 200) {
			if(target.indexOf("api")!=-1){
				target = "/api/error";
			}


		}
		response.addHeader("Access-Control-Allow-Origin", "*");
		next.handle(target, request, response, isHandled);
	}

}
